﻿namespace ExamV5
{
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmTop : Page
    {
        protected HtmlForm form1;
        //protected Image ImgSM;
        //protected Label labDate;
        protected Label labTip;
        protected Label labTopMenu;
        protected Label labUserInfo;
        private PublicFun publicFun_0 = new PublicFun();

        private void method_0()
        {
            PublicFun fun = new PublicFun();
            string strSql = "";
            strSql = "select  a.ID from SysTip a,UserInfo b where a.GetNumber=b.UserCode and  FormType='A' and (a.GetNumber='" + fun.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamUserCode"].Value)) + "') and a.Flag='A'";
            string values = fun.GetValues(strSql, "ID");
            if (!((values.Trim() != "") ? !(values.Trim() != "0") : true))
            {
                this.labTip.Text = "<A onfocus='this.blur();' href='#' OnClick=javascript:window.parent.MainFrame.location.href='Persion/HelpInfoList.aspx';><img src=\"Image/images/tixing.png\" /><font color=red></font></A>";
            }
            else
            {
                this.labTip.Text = "";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = null;
            cookie = new HttpCookie("ExamUserCode");
            cookie = base.Request.Cookies["ExamUserCode"];
            if ((cookie != null) ? !(cookie.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                if (!base.IsPostBack)
                {
                    this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                    string str2 = "A";
                    this.labUserInfo.Text = this.publicFun_0.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamUserName"].Value)) + "\x00b7" + this.publicFun_0.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamDeptName"].Value));
                    if (this.labUserInfo.Text.Length > 12)
                    {
                        this.labUserInfo.Text = "<a title='" + this.labUserInfo.Text + "'><font color='#303030'>" + this.labUserInfo.Text.Substring(0, 12) + "</font></a>";
                    }
                    if (!(base.Server.UrlDecode(base.Request.Cookies["ExamUserLevel"].Value) == "A"))
                    {
                        str2 = "C";
                        //this.ImgSM.ImageUrl = "image/HeadManag.gif";
                    }
                    else
                    {
                        str2 = "A";
                        //this.ImgSM.ImageUrl = "image/HeadStudio.gif";
                    }
                    //this.labDate.Text = "<font color='#ffffff'>" + DateTime.Now.ToLongDateString() + "</font>";
                    //if (ConfigurationManager.ConnectionStrings["WriteInfo"].ConnectionString == "1")
                    //{
                    //    this.labDate.Text = this.labDate.Text + "&nbsp; <A onfocus='this.blur();' href='#' OnClick=javascript:window.parent.MainFrame.location.href='FrmVersion.aspx'; title='关于我们'><img src='Image/MenuICO/MenuAbus.gif' border='0'/></A>";
                    //}


                    this.labTopMenu.Text = "<ul class=\"layui-nav layui-layout-left nav_top\">";
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                    connection.Open();
                    SqlCommand command = new SqlCommand("select ID,MenuTitle,MenuICO  from SysMenu where UPID=0 and (MenuTitle like '%交流%' or IsShow='" + str2 + "') and IsHide='N' and (BrowUserCode like '%,所有人员,%' or BrowUserCode like '," + this.publicFun_0.CheckString(base.Server.UrlDecode(base.Request.Cookies["ExamUserCode"].Value)) + ",') order by MenuSort", connection);
                    SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                    while (reader.Read())
                    {
                        //this.labTopMenu.Text = this.labTopMenu.Text + "<td background='image/HeadMenuAA.gif' width='159'  height='52' onmousemove=this.style.cursor='hand'  onmouseover=javascript:BGChanged(this,0); onmouseout=javascript:BGChanged(this,1); align='center' class='HeadTitleFont'  onclick=javascript:window.parent.MenuFrame.location.href='FrmLeftMenu.aspx?UPID=" + reader["ID"].ToString() + "';><img src='" + reader["MenuICO"].ToString() + "' border='0' /><font color='#ffffff'> " + reader["MenuTitle"].ToString() + "</font></td>";
                        this.labTopMenu.Text = this.labTopMenu.Text + "<li class=\"layui-nav-item\"><a href=\"#\" onclick=\"javascript:GomainByUPID(" + reader["ID"].ToString() + ");\">" + reader["MenuTitle"].ToString() + "</a></li>";
                    }
                    reader.Close();
                    command.Dispose();
                    connection.Close();
                    connection.Dispose();
                    this.labTopMenu.Text = this.labTopMenu.Text + "</ul>";



                    this.method_0();
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='Index.htm';self.close();</script>");
            }
        }
    }
}

